Optimal. Leaf size=143 \[ -\frac {2 b^2 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 \sqrt {a-b} \sqrt {a+b} d}+\frac {\left (a^2 A+2 A b^2-2 a b B\right ) \tanh ^{-1}(\sin (c+d x))}{2 a^3 d}-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {A \sec (c+d x) \tan (c+d x)}{2 a d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.31, antiderivative size = 143, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.194, Rules used = {3079, 3134,
3080, 3855, 2738, 211} \begin {gather*} -\frac {2 b^2 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 d \sqrt {a-b} \sqrt {a+b}}-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {\left (a^2 A-2 a b B+2 A b^2\right ) \tanh ^{-1}(\sin (c+d x))}{2 a^3 d}+\frac {A \tan (c+d x) \sec (c+d x)}{2 a d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 3079
Rule 3080
Rule 3134
Rule 3855
Rubi steps
\begin {align*} \int \frac {(A+B \cos (c+d x)) \sec ^3(c+d x)}{a+b \cos (c+d x)} \, dx &=\frac {A \sec (c+d x) \tan (c+d x)}{2 a d}+\frac {\int \frac {\left (-2 (A b-a B)+a A \cos (c+d x)+A b \cos ^2(c+d x)\right ) \sec ^2(c+d x)}{a+b \cos (c+d x)} \, dx}{2 a}\\ &=-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {A \sec (c+d x) \tan (c+d x)}{2 a d}+\frac {\int \frac {\left (a^2 A+2 A b^2-2 a b B+a A b \cos (c+d x)\right ) \sec (c+d x)}{a+b \cos (c+d x)} \, dx}{2 a^2}\\ &=-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {A \sec (c+d x) \tan (c+d x)}{2 a d}-\frac {\left (b^2 (A b-a B)\right ) \int \frac {1}{a+b \cos (c+d x)} \, dx}{a^3}+\frac {\left (a^2 A+2 A b^2-2 a b B\right ) \int \sec (c+d x) \, dx}{2 a^3}\\ &=\frac {\left (a^2 A+2 A b^2-2 a b B\right ) \tanh ^{-1}(\sin (c+d x))}{2 a^3 d}-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {A \sec (c+d x) \tan (c+d x)}{2 a d}-\frac {\left (2 b^2 (A b-a B)\right ) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{a^3 d}\\ &=-\frac {2 b^2 (A b-a B) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 \sqrt {a-b} \sqrt {a+b} d}+\frac {\left (a^2 A+2 A b^2-2 a b B\right ) \tanh ^{-1}(\sin (c+d x))}{2 a^3 d}-\frac {(A b-a B) \tan (c+d x)}{a^2 d}+\frac {A \sec (c+d x) \tan (c+d x)}{2 a d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(300\) vs. \(2(143)=286\).
time = 1.76, size = 300, normalized size = 2.10 \begin {gather*} \frac {\frac {8 b^2 (A b-a B) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}-2 \left (a^2 A+2 A b^2-2 a b B\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 \left (a^2 A+2 A b^2-2 a b B\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+\frac {a^2 A}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {4 a (-A b+a B) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )}-\frac {a^2 A}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {4 a (-A b+a B) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )}}{4 a^3 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.54, size = 229, normalized size = 1.60
method | result | size |
derivativedivides | \(\frac {-\frac {A}{2 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{2}}-\frac {-a A -2 A b +2 a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {\left (a^{2} A +2 A \,b^{2}-2 B a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 a^{3}}-\frac {2 b^{2} \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{3} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {A}{2 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{2}}-\frac {-a A -2 A b +2 a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}+\frac {\left (-a^{2} A -2 A \,b^{2}+2 B a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 a^{3}}}{d}\) | \(229\) |
default | \(\frac {-\frac {A}{2 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{2}}-\frac {-a A -2 A b +2 a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}+\frac {\left (a^{2} A +2 A \,b^{2}-2 B a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 a^{3}}-\frac {2 b^{2} \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{3} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {A}{2 a \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{2}}-\frac {-a A -2 A b +2 a B}{2 a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}+\frac {\left (-a^{2} A -2 A \,b^{2}+2 B a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 a^{3}}}{d}\) | \(229\) |
risch | \(-\frac {i \left (A a \,{\mathrm e}^{3 i \left (d x +c \right )}+2 A b \,{\mathrm e}^{2 i \left (d x +c \right )}-2 B a \,{\mathrm e}^{2 i \left (d x +c \right )}-a A \,{\mathrm e}^{i \left (d x +c \right )}+2 A b -2 a B \right )}{a^{2} d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{2 d a}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A \,b^{2}}{a^{3} d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B b}{a^{2} d}-\frac {A \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{2 d a}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A \,b^{2}}{a^{3} d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B b}{a^{2} d}-\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d \,a^{3}}+\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,a^{2}}+\frac {b^{3} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d \,a^{3}}-\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) B}{\sqrt {-a^{2}+b^{2}}\, d \,a^{2}}\) | \(520\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 260 vs.
\(2 (129) = 258\).
time = 2.81, size = 589, normalized size = 4.12 \begin {gather*} \left [\frac {2 \, {\left (B a b^{2} - A b^{3}\right )} \sqrt {-a^{2} + b^{2}} \cos \left (d x + c\right )^{2} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right ) + {\left (A a^{4} - 2 \, B a^{3} b + A a^{2} b^{2} + 2 \, B a b^{3} - 2 \, A b^{4}\right )} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (A a^{4} - 2 \, B a^{3} b + A a^{2} b^{2} + 2 \, B a b^{3} - 2 \, A b^{4}\right )} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (A a^{4} - A a^{2} b^{2} + 2 \, {\left (B a^{4} - A a^{3} b - B a^{2} b^{2} + A a b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{4 \, {\left (a^{5} - a^{3} b^{2}\right )} d \cos \left (d x + c\right )^{2}}, \frac {4 \, {\left (B a b^{2} - A b^{3}\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right ) \cos \left (d x + c\right )^{2} + {\left (A a^{4} - 2 \, B a^{3} b + A a^{2} b^{2} + 2 \, B a b^{3} - 2 \, A b^{4}\right )} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (A a^{4} - 2 \, B a^{3} b + A a^{2} b^{2} + 2 \, B a b^{3} - 2 \, A b^{4}\right )} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (A a^{4} - A a^{2} b^{2} + 2 \, {\left (B a^{4} - A a^{3} b - B a^{2} b^{2} + A a b^{3}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{4 \, {\left (a^{5} - a^{3} b^{2}\right )} d \cos \left (d x + c\right )^{2}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (A + B \cos {\left (c + d x \right )}\right ) \sec ^{3}{\left (c + d x \right )}}{a + b \cos {\left (c + d x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 269 vs.
\(2 (129) = 258\).
time = 0.47, size = 269, normalized size = 1.88 \begin {gather*} \frac {\frac {{\left (A a^{2} - 2 \, B a b + 2 \, A b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a^{3}} - \frac {{\left (A a^{2} - 2 \, B a b + 2 \, A b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a^{3}} - \frac {4 \, {\left (B a b^{2} - A b^{3}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} a^{3}} + \frac {2 \, {\left (A a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 2 \, B a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, A b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + A a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 2 \, B a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, A b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{2} a^{2}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 4.21, size = 2500, normalized size = 17.48 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________